import * as api from "./api";
import {dict} from "@fast-crud/fast-crud";
// 构建crudOptions的方法
export default function ({expose}) {
  const pageRequest = async (query) => {
    return await api.GetList(query);
  };
  const editRequest = async ({form, row}) => {
    form.id = row.id;
    return await api.UpdateObj(form);
  };
  const delRequest = async (id) => {
    return await api.DelObj(id);
  };

  const addRequest = async ({form}) => {
    return await api.AddObj(form);
  };
  return {
    crudOptions: {
      //请求配置
      request: {
        pageRequest, // 列表数据请求
        addRequest,  // 添加请求
        editRequest, // 修改请求
        delRequest,  // 删除请求
      },
      columns: {
      <#list table.fields as field>
        ${field.propertyName}: {
          title: '${field.comment}',
          type: 'text',
        }<#if field_has_next>,</#if>
      </#list>
      },
      // 其他crud配置
    },
  };
}
